<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <link rel="stylesheet" href="css/style.css">
  <style>
    [id*="instance"] .demo {
      background: url(./img/merry_christmas.jpg) no-repeat;
      background-size: 100% 100%;
    }
  </style>
</head>
<body>
<div id="instance">
  <div class="demo"></div>
  <div class="btn-box">
    <button class="btn btn-primary" type="button" data-open>
      open
    </button>
    <button class="btn btn-danger" type="button" data-pause>
      pause
    </button>
  </div>
</div>

<div id="instance2">
  <div class="demo"></div>
  <div class="btn-box">
    <button class="btn btn-primary" type="button" data-open>
      open
    </button>
    <button class="btn btn-danger" type="button" data-pause>
      pause
    </button>
  </div>
</div>

<div id="instance3">
  <div class="demo"></div>
  <div class="btn-box">
    <button class="btn btn-primary" type="button" data-open>
      open
    </button>
    <button class="btn btn-danger" type="button" data-pause>
      pause
    </button>
  </div>
</div>

<div id="instance4">
  <div class="demo"></div>
  <div class="btn-box">
    <button class="btn btn-primary" type="button" data-open>
      open
    </button>
    <button class="btn btn-danger" type="button" data-pause>
      pause
    </button>
  </div>
</div>

<script src="js/event.js"></script>
<script>
  const base64PNG = ''

  // 测试 base64 格式
  bind('#instance', function() {
    return new JParticles.Snow('#instance .demo', {
      maxR: 30,
      minR: 10,
      maxSpeed: 0.2,
      shape: base64PNG,
      spin: true,
      spinMaxSpeed: 20,
      spinMinSpeed: 1,
    })
  })

  // 测试「内置」形状
  bind('#instance2', function() {
    return new JParticles.Snow('#instance2 .demo', {
      maxR: 10,
      minR: 10,
      maxSpeed: 0.2,
      // star:[边数][凹值]
      shape: ['circle', 'triangle', 'star', 'star:4:0.2', 'star:6:1.5'],
      spin: true,
    })
  })

  // 测试 HTTP 格式
  bind('#instance3', function() {
    return new JParticles.Snow('#instance3 .demo', {
      maxR: 20,
      minR: 20,
      maxSpeed: 0.2,
      minSpeed: 0.2,
      swing: false,
      shape: [
        'https://img10.360buyimg.com/ling/jfs/t1/180952/11/13170/68465/60e6e46fE8d8e4f15/453c2896998eda6d.png',
        'https://img10.360buyimg.com/ling/jfs/t1/182564/22/13408/6442/60e6ee1bE014c0d60/6ef57767e19999b2.png',
        'https://raw.githubusercontent.com/Barrior/assets/main/chrome-logo.svg'
      ],
      spin: true,
    })
  })

  // 测试 HTMLImageElement 格式
  JParticles.utils.loadImage('https://img10.360buyimg.com/ling/jfs/t1/180952/11/13170/68465/60e6e46fE8d8e4f15/453c2896998eda6d.png', (image) => {
    bind('#instance4', function () {
      return new JParticles.Snow('#instance4 .demo', {
        maxR: 20,
        minR: 20,
        maxSpeed: 0.2,
        minSpeed: 0.2,
        shape: image,
        spin: true,
      })
    })
  })

</script>
</body>
</html>
